<template>
    <el-form-item label="出价" :prop="`delivery.cpa_bid`">
        <div class="flexbox flexcenter">
            <el-input placeholder="" v-model="createform.delivery.cpa_bid" @change="sessionSave" size="small" style="width:143px">
                <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-if="createform.external_action=='AD_CONVERT_TYPE_SHOPPING'">元/下单</span>
                <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-else-if="createform.external_action=='AD_CONVERT_TYPE_QC_FOLLOW_ACTION'">元/关注</span>
                <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-else-if="createform.external_action=='AD_CONVERT_TYPE_QC_MUST_BUY'">元/点击</span>
                <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-else-if="createform.external_action=='AD_CONVERT_TYPE_LIVE_ENTER_ACTION'">元/观看</span>
                <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-else-if="createform.external_action=='AD_CONVERT_TYPE_LIVE_CLICK_PRODUCT_ACTION'">元/点击</span>
                <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-else-if="createform.external_action=='AD_CONVERT_TYPE_LIVE_SUCCESSORDER_ACTION'">元/下单</span>
                <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-else-if="createform.external_action=='AD_CONVERT_TYPE_LIVE_SUCCESSORDER_PAY'">元/成交</span>
                <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-else-if="createform.external_action=='AD_CONVERT_TYPE_NEW_FOLLOW_ACTION'">元/关注</span>
                <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-else-if="createform.external_action=='AD_CONVERT_TYPE_LIVE_COMMENT_ACTION'">元/评论</span>
                <!-- <span slot="suffix" style="line-height:32px;color:#17233D;margin-right:5px" v-else-if="createform.external_action=='AD_CONVERT_TYPE_LIVE_SUCCESSORDER_PAY_7DAYS'">元/7日总成交</span> -->
            </el-input>
            <el-link type="primary" :underline="false" style="margin-left:12px" @click="addBulkBid">
                <div class="flexbox flexcenter">
                    <img src="../../../assets/img/offer_add.svg" alt="" style="margin-right:5px">
                    批量出价
                </div>
            </el-link>
        </div>
    </el-form-item>
</template>

<script>
export default {
    props:["createform"],
    name: "",
    data() {
        return {};
    },
    created() {},
    methods: {
        // 批量出价
        addBulkBid() {
            let reg =
                /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
            if (!reg.test(this.createform.delivery.cpa_bid)) {
                this.$message.error("请正确输入出价");
                return;
            } else if (
                Number(this.createform.delivery.cpa_bid) < 0.1 ||
                Number(this.createform.delivery.cpa_bid) > 10000
            ) {
                this.$message.error("请正确输入出价");
                return;
            }

            if (
                Number(this.createform.delivery.cpa_bid) >
                Number(this.createform.delivery.budget)
            ) {
                this.$message.error("出价不得高于预算");
                return;
            }
            if (
                this.createform.delivery.video_schedule_type ==
                "SCHEDULE_START_END"
            ) {
                if (this.createform.delivery.delivery_time.length == 0) {
                    this.$message.error("用户出价投放开始和结束时间不能为空");
                    return;
                }
            }
            if (this.createform.budget_list.length == 10) {
                this.$message.error("已超出模板数量限制！");
                return;
            }
            const attr = {
                dialogVsb: true,
                number: 10 - this.createform.budget_list.length,
                info: this.createform.delivery,
            };
            this.$bus.emit("addBulkBid", attr);
        },

        sessionSave(){
            this.$emit("sessionSave")
        }
    },
    components: {},
};
</script>


<style scoped>
</style>

